package com.nustalk;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ScrollView;

public class TChatActivity extends Activity {
	EditText chatBox, msgBox;
	Button sendButton;
	ScrollView scroller;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tchat);
        scroller = (ScrollView)findViewById(R.id.scroller);
		chatBox = (EditText)findViewById(R.id.chatBox);
		msgBox = (EditText)findViewById(R.id.msgBox);
		sendButton = (Button)findViewById(R.id.sendButton);
		sendButton.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				chatBox.append(msgBox.getText() + "\n");
				scroller.post(new Runnable() { 
	                public void run() { 
	                    scroller.smoothScrollTo(0, msgBox.getBottom());
	                } 
	            });
			}
		});
    }
}